/*
 * @Author: your name
 * @Date: 2022-01-29 19:19:45
 * @LastEditTime: 2022-02-04 09:45:11
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \testHtmld:\SoftWareProject\mySoft\myNode\seleniumWeb1.js
 */
/**
 * 使用 selenium - web 爬虫小说网站
 */
const {
  Builder,
  By,
  Key,
  until
} = require('selenium-webdriver');

(async function example() {

  let driver = await new Builder().forBrowser('firefox').build();
  try {
    await driver.get('https://m.banzhuchilaohu.com/indexlist/2916/');
    // await driver.findElement(By.id('cboxClose')).click()

    // await driver.findElement(By.id('kw')).sendKeys('前端', Key.RETURN);
    let items = await driver.findElements(By.css('.chapter li'));
    var list = []
    for (let i = 0; i < items.length; i++) {
      let item = items[i];
      // console.log(await  item.getText())
      let title = await item.findElement(By.css("a")).getText();
      let url = await item.findElement(By.css("a")).getAttribute("href");
      list.push({
        title,
        url
      });

    }
    console.log(list);

  } finally {
    // await driver.quit();
  }
})();